this is code to analyze the data

Figures for 3D Liver Print Systematic Scoping Review

This document provides code for importing and cleaning data from the systematic review that was used to create all figures provided in the submitted manuscript.

Figure 1 - Printing Methods

Figure 1a - Kind of printing method used

print_method <- reconciled %>%  
                  select(study_ID, 
                   `4.1 What kind of printing method is used?_ae684e28-4f90-44ad-9de2-731d076de0b0_Answer`) %>% 
                  separate_rows(`4.1 What kind of printing method is used?_ae684e28-4f90-44ad-9de2-731d076de0b0_Answer`, sep="\\|")


print_method <- print_method %>% 
  mutate(`4.1 What kind of printing method is used?_ae684e28-4f90-44ad-9de2-731d076de0b0_Answer`= recode(`4.1 What kind of printing method is used?_ae684e28-4f90-44ad-9de2-731d076de0b0_Answer`, "Extrusion based" = "Extrusion")) %>% 
  mutate(`4.1 What kind of printing method is used?_ae684e28-4f90-44ad-9de2-731d076de0b0_Answer`= recode(`4.1 What kind of printing method is used?_ae684e28-4f90-44ad-9de2-731d076de0b0_Answer`, "Inject based" = "Injection"))

t1 <- table(print_method$`4.1 What kind of printing method is used?_ae684e28-4f90-44ad-9de2-731d076de0b0_Answer`)

t1# manually set levels 
## 
##         Extrusion         Injection             Other Stereolithography 
##                39                 4                12                 3 
##           Unclear 
##                 6
t1_sorted<- t1 %>% as.data.frame() %>% arrange(factor(Var1, levels = c("Stereolithography", "Extrusion", "Injection", "Other", "Unclear")))

data_bar1 <- t1_sorted$Freq
names(data_bar1) <- t1_sorted$Var1


# barplot(data_bar13)
text(x = barplot(
#  colnames<-(t(t13_sorted[-1]), t13_sorted[,1]), 
 # 'labels' <- (t(t13_sorted[-1]), t13_sorted[,1])), 
  # t(as.matrix(t13_sorted)), 
   data_bar1,
  ylab = "Number of Studies", ylim=c(0, max(data_bar1) + 10), cex.names=1 , col = "#33a02c", #main = "What kind of printing method was used?"
  ), y = data_bar1 + 2, labels = data_bar1, 
  cex = 1)

# text(x = barplot(t1, ylab = "Number of studies", ylim=c(0, max(t1) + 10), cex.names=0.8, col = "green", main = "What kind of printing method was used?", las=0), y = t1 + 2, labels = t1, cex = 0.8 )

Figure 1b - What forms are printed with the ink?

# Data cleaning
# Those with a semicolon response ; should now be called "combo"
# responses separate with a pipe should be merged when they are saying the same thing. 
printer_forms <- reconciled %>% 
  mutate(`4.1.4 What kind of forms are printed with this ink?_01d3ca37-1e2f-4087-8f39-c183f98f0c4e_Answer`= recode(`4.1.4 What kind of forms are printed with this ink?_01d3ca37-1e2f-4087-8f39-c183f98f0c4e_Answer`, "Grid|Grid" = "Grid")) %>% 
  mutate(`4.1.4 What kind of forms are printed with this ink?_01d3ca37-1e2f-4087-8f39-c183f98f0c4e_Answer`= recode(`4.1.4 What kind of forms are printed with this ink?_01d3ca37-1e2f-4087-8f39-c183f98f0c4e_Answer`, "lobular liver|lobular liver" = "lobular liver")) %>% 
  mutate(`4.1.4 What kind of forms are printed with this ink?_01d3ca37-1e2f-4087-8f39-c183f98f0c4e_Answer`= recode(`4.1.4 What kind of forms are printed with this ink?_01d3ca37-1e2f-4087-8f39-c183f98f0c4e_Answer`, "Other|Other" = "Other")) %>% 
  mutate(`4.1.4 What kind of forms are printed with this ink?_01d3ca37-1e2f-4087-8f39-c183f98f0c4e_Answer`= recode(`4.1.4 What kind of forms are printed with this ink?_01d3ca37-1e2f-4087-8f39-c183f98f0c4e_Answer`, "Grid;Other" = "Combination")) %>% 
  mutate(`4.1.4 What kind of forms are printed with this ink?_01d3ca37-1e2f-4087-8f39-c183f98f0c4e_Answer`= recode(`4.1.4 What kind of forms are printed with this ink?_01d3ca37-1e2f-4087-8f39-c183f98f0c4e_Answer`, "lobular liver;Other" = "Combination")) 

printer_forms <-  printer_forms %>% 
mutate(`4.1.4 What kind of forms are printed with this ink?_01d3ca37-1e2f-4087-8f39-c183f98f0c4e_Answer`= recode(`4.1.4 What kind of forms are printed with this ink?_01d3ca37-1e2f-4087-8f39-c183f98f0c4e_Answer`, "lobular liver" = "Lobular Liver"))

t4 <-table(printer_forms$`4.1.4 What kind of forms are printed with this ink?_01d3ca37-1e2f-4087-8f39-c183f98f0c4e_Answer`)

t4_sorted<- t4 %>% as.data.frame() %>% arrange(factor(Var1, levels = c("Grid", "Lobular Liver", "Toroids", "Combination", "Other")))

data_bar4 <- t4_sorted$Freq
names(data_bar4) <- t4_sorted$Var1

text(x = barplot(
#  colnames<-(t(t13_sorted[-1]), t13_sorted[,1]), 
 # 'labels' <- (t(t13_sorted[-1]), t13_sorted[,1])), 
  # t(as.matrix(t13_sorted)), 
   data_bar4,
  ylab = "Number of Studies", ylim=c(0, max(data_bar4) + 10), cex.names=1 , col = "#33a02c"
  #, main = "What kind of forms are printed with this ink?"
  ), y = data_bar4 + 2, labels = data_bar4, 
  cex = 1)

# text(x = barplot(t4, ylab = "Number of studies", ylim=c(0, max(t4) + 10), cex.names=.8 , col = "green", main = "What kind of forms are printed with this ink?"), y = t4 + 2, labels = t4, cex = 0.8)

change order to: ” Grid - Lobular Liver - Toroids - Combination - Other” - done ABB

Figure 1c - Which printing methods are used which which bioink?

Interactive sankey diagram - hover over each section to see the number of experiments in each category.

library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
#### prep data for sankey diagram
# type --> 
Print_bioink <- reconciled %>%select(
  study_ID, 
  `4.1 What kind of printing method is used?_ae684e28-4f90-44ad-9de2-731d076de0b0_Answer`,
  `4.1.3 What type of bioink was used?_92421414-c597-4e9c-b720-9bb4318b5483_Answer`, 
  `4.1.3.1.1 If natural bioink, please choose the type._66b761ad-6630-4323-b423-c848a717aae4_Answer`, 
  `4.1.3.1.4 If Synthetic bioink: choose the type _e74ea0e0-a654-4ae2-b59e-2e0b14a4651a_Answer`, 
  `4.1.3.1.2 If Protein based: choose the type._621671b3-9f7e-4a22-80ac-14b02fdd0683_Answer`, 
  `4.1.3.1.3 If Polysaccharides Based: choose the type. _fcea8bcb-da6c-4154-aa44-8ff4734fa4fe_Answer`
)  


Print_bioink <- Print_bioink  %>% rename(
  print_method = `4.1 What kind of printing method is used?_ae684e28-4f90-44ad-9de2-731d076de0b0_Answer`,
  typeGeneral_level1 = `4.1.3 What type of bioink was used?_92421414-c597-4e9c-b720-9bb4318b5483_Answer`, 
  typeNatural_level2 = `4.1.3.1.1 If natural bioink, please choose the type._66b761ad-6630-4323-b423-c848a717aae4_Answer`, 
  typeSynthetic_level2 = `4.1.3.1.4 If Synthetic bioink: choose the type _e74ea0e0-a654-4ae2-b59e-2e0b14a4651a_Answer`, 
  typeProtein_level3 = `4.1.3.1.2 If Protein based: choose the type._621671b3-9f7e-4a22-80ac-14b02fdd0683_Answer`, 
  typePoly_level3 = `4.1.3.1.3 If Polysaccharides Based: choose the type. _fcea8bcb-da6c-4154-aa44-8ff4734fa4fe_Answer`
)



Print_bioink1 <- Print_bioink %>% 
                separate_rows(print_method , sep="\\|") %>% 
              separate_rows(typeGeneral_level1, sep="\\|") 

Print_bioink1$print_method <- as.factor(Print_bioink1$print_method)
Print_bioink1$typeGeneral_level1 <- as.factor(Print_bioink1$typeGeneral_level1 )
  
# summary(Print_bioink1)

Print_bioink1_sankey <- Print_bioink1 %>% select(study_ID, print_method, typeGeneral_level1)


# create a table of frequencies
freq_table <- Print_bioink1_sankey %>% group_by(print_method, typeGeneral_level1) %>% 
  summarise(n = n())
## `summarise()` has grouped output by 'print_method'. You can override using the
## `.groups` argument.
freq_table <- freq_table %>% 
   mutate(print_method= recode(print_method, "Unclear" = "Unclear - Method")) %>% 
     mutate(typeGeneral_level1= recode(typeGeneral_level1, "Unclear" = "Unclear - Bioink"))


# create a nodes data frame
nodes <- data.frame(name = unique(c(as.character(freq_table$print_method),
                                    as.character(freq_table$typeGeneral_level1))))


# create links dataframe
links <- data.frame(source = match(freq_table$print_method, nodes$name) - 1,
                    target = match(freq_table$typeGeneral_level1, nodes$name) - 1,
                    value = freq_table$n,
                    stringsAsFactors = FALSE)



# Make Sankey diagram
plot_ly(
  type = "sankey",
  orientation = "h",
  node = list(pad = 15,
              thickness = 20,
              line = list(color = "black", width = 0.5),
              label = nodes$name),
  link = list(source = links$source,
              target = links$target,
              value = links$value),
  textfont = list(size = 10),
  width = 720,
  height = 480
) %>%
  layout(title = "Sankey Diagram: Print Method & Ink Type",
         font = list(size = 14),
         margin = list(t = 40, l = 10, r = 10, b = 10))

Figure 1d - What “Other” printed forms are used?

library(stringr)

print_form_comment_other <- tibble( 
   study_ID = reconciled$study_ID, 
   method =  reconciled$`4.1.4 What kind of forms are printed with this ink?_01d3ca37-1e2f-4087-8f39-c183f98f0c4e_Answer`, 
   comment = reconciled$`4.1.4 What kind of forms are printed with this ink?_01d3ca37-1e2f-4087-8f39-c183f98f0c4e_Comments`) 

print_form_comment_other <- print_form_comment_other %>% 
                  separate_rows(method, sep="\\|") %>%  
                  subset(method == "Other")

print_form_comment_other <- print_form_comment_other %>% 
                  separate_rows(comment, sep="\\|")

# remove line breaks
print_form_comment_other$comment <- str_replace_all(print_form_comment_other$comment, "[\n]" , "")

# remove whitespace from start of str
print_form_comment_other$comment <- str_trim(print_form_comment_other$comment, "left")

# remove whitespace from end of str
print_form_comment_other$comment <- str_trim(print_form_comment_other$comment, "right")

# turn variable into a factor to group similar
#print_form_comment_other$comment <- as.factor(print_form_comment_other$comment)

 table(print_form_comment_other$comment)
## 
## Complex,  perfusable architectures                          cruciform 
##                                  1                                  1 
##                              donut                            doplets 
##                                  4                                  1 
##                           droplets                         gear shape 
##                                  8                                  1 
##                          hexagonal               hexagonal constructs 
##                                  1                                  1 
##                          honeycomb                              lines 
##                                  1                                  3 
##                          not clear                  printed on a chip 
##                                  1                                  5 
##                 printing on a chip                          rectangle 
##                                  1                                  1 
##                         sinusoidal                           spheroid 
##                                  1                                  1 
##                          spheroids                             square 
##                                  2                                  1 
##    two-compartment planar geometry 
##                                  7
# is.data.frame(print_form_comment_other)
 
# rename answers to more easily group them
print_form_comment_other <- print_form_comment_other %>% 
      mutate(comment = recode(comment, "doplets" = "droplets")) %>% 
      mutate(comment = recode(comment, "printing on a chip" = "printed on a chip")) %>%   
     mutate(comment = recode(comment, "spheroid" = "spheroids")) %>%
     mutate(comment = recode(comment, "hexagonal constructs" = "hexagonal"))%>%
     mutate(comment = recode(comment, "not clear" = "unclear"))
             

# group by numbers
commentsPrintForm <- print_form_comment_other %>%  group_by(comment) %>% summarise(n_unique = length(unique(study_ID))) %>%  arrange(desc(n_unique))

names(commentsPrintForm) <- c("Printer Form", "Number of Unique Studies")

#install.packages("formattable")
library(formattable)
## 
## Attaching package: 'formattable'
## The following object is masked from 'package:plotly':
## 
##     style
formattable(commentsPrintForm,
            align =c("l", "r"),
            list(`Indicator Name` = formatter(
              "span", style = ~ style(color = "grey",font.weight = "bold")), 
              `Number of Unique Studies`= color_bar("#33a02c")
))
Printer Form Number of Unique Studies
droplets 6
two-compartment planar geometry 4
printed on a chip 3
spheroids 3
hexagonal 2
lines 2
Complex, perfusable architectures 1
cruciform 1
donut 1
gear shape 1
honeycomb 1
rectangle 1
sinusoidal 1
square 1
unclear 1

CHange “not clear” to “unclear” - done ABB

Figure 2 - BioInks

Figure 2a - What bioinks were used?

Interactive Sunburst plot - hover over each section to see the number of experiments in each category.

#### BIOINK sunburst 

library(plotme)

# type --> 
bioink <- reconciled %>% select(
  study_ID, 
    `4.1.3 What type of bioink was used?_92421414-c597-4e9c-b720-9bb4318b5483_Answer`, 
    `4.1.3.1.1 If natural bioink, please choose the type._66b761ad-6630-4323-b423-c848a717aae4_Answer`, 
    `4.1.3.1.4 If Synthetic bioink: choose the type _e74ea0e0-a654-4ae2-b59e-2e0b14a4651a_Answer`, `4.1.3.1.2 If Protein based: choose the type._621671b3-9f7e-4a22-80ac-14b02fdd0683_Answer`, 
`4.1.3.1.3 If Polysaccharides Based: choose the type. _fcea8bcb-da6c-4154-aa44-8ff4734fa4fe_Answer`
  )  


bioink <- bioink  %>% rename(typeGeneral_level1 = `4.1.3 What type of bioink was used?_92421414-c597-4e9c-b720-9bb4318b5483_Answer`, 
   typeNatural_level2 = `4.1.3.1.1 If natural bioink, please choose the type._66b761ad-6630-4323-b423-c848a717aae4_Answer`, 
  typeSynthetic_level2 = `4.1.3.1.4 If Synthetic bioink: choose the type _e74ea0e0-a654-4ae2-b59e-2e0b14a4651a_Answer`, 
  typeProtein_level3 = `4.1.3.1.2 If Protein based: choose the type._621671b3-9f7e-4a22-80ac-14b02fdd0683_Answer`, 
  typePoly_level3 = `4.1.3.1.3 If Polysaccharides Based: choose the type. _fcea8bcb-da6c-4154-aa44-8ff4734fa4fe_Answer`
)



### other is Matrigel

bioink_split1 <- separate_rows(bioink, typeGeneral_level1 , sep="\\|")
bioink_split1_1 <- separate_rows(bioink_split1, typeNatural_level2 , sep="\\|")
bioink_split1_2 <- separate_rows(bioink_split1_1, typeProtein_level3 , sep="\\|")
bioink_split1_3 <- separate_rows(bioink_split1_2, typePoly_level3 , sep="\\|")

bioink_split2 <- separate_rows(bioink_split1_3, typeNatural_level2 , sep=";")
bioink_split3 <- separate_rows(bioink_split2, typeProtein_level3 , sep=";")
bioink_split3 <- separate_rows(bioink_split3, typePoly_level3 , sep=";")
# 164 rows

test_bio <- bioink_split1_3 %>%
     mutate(
typeNatural_level2 = replace(typeNatural_level2, typeGeneral_level1!="Natural", NA), typeSynthetic_level2 = replace(typeSynthetic_level2, typeGeneral_level1!="Synthetic", NA), typeProtein_level3 = replace(typeProtein_level3, typeNatural_level2!="Protein based", NA), 
typeProtein_level3 = replace(typeProtein_level3, typeGeneral_level1!="Natural", NA), 
typePoly_level3 =  replace(typePoly_level3, typeNatural_level2!="Polysaccharide based", NA), 
typePoly_level3 =  replace(typePoly_level3, typeGeneral_level1!="Natural", NA)
            )


test_bio$typeSynthetic_level2 <- as.character(test_bio$typeSynthetic_level2)
  

### merge level 2 & merge level 3 
test_bio$level3 <- ifelse(!is.na(test_bio$typeProtein_level3), test_bio$typeProtein_level3, test_bio$typePoly_level3)
test_bio$level2 <- ifelse(!is.na(test_bio$typeNatural_level2), test_bio$typeNatural_level2, test_bio$typeSynthetic_level2)

  
# table(test_bio$level3)


# rename answers to more easily group them
# test_bio <- test_bio %>% 
#       mutate(level3 = recode(level3, "Collagens" = "Collagen")) %>% 
#       mutate(level2 = recode(level2, "Poly ethylene glycol (PEG)" = "PEG"))  
# # %>%      mutate(level2 = recode(level2, "Poly ethylene glycol (PEG)" = "PEG"))  
#   
  


#################### update after discussion with experts on interpretation
bioink_split1 <- separate_rows(bioink, typeGeneral_level1 , sep="\\|")

bioInk_72 <- bioink_split1 %>%
     mutate(
typeNatural_level2 = replace(typeNatural_level2, typeGeneral_level1!="Natural", NA), 
typeSynthetic_level2 = replace(typeSynthetic_level2, typeGeneral_level1!="Synthetic", NA), 
typeProtein_level3 = replace(typeProtein_level3, typeNatural_level2!="Protein based", NA), 
typeProtein_level3 = replace(typeProtein_level3, typeGeneral_level1!="Natural", NA), 
typePoly_level3 =  replace(typePoly_level3, typeNatural_level2!="Polysaccharide based", NA), 
typePoly_level3 =  replace(typePoly_level3, typeGeneral_level1!="Natural", NA)
            )

# turn all cols to character
bioInk_72 <- bioink_split1 %>%
  mutate(across(everything(), as.character))

#str(bioInk_72)

##### level 3 
bioInk_72$level3 <- paste(bioInk_72$typeProtein_level3, bioInk_72$typePoly_level3)

bioInk_72$level3 <- ifelse(!is.na(bioInk_72$typeProtein_level3),  bioInk_72$typeProtein_level3, bioInk_72$typePoly_level3)

# bioInk_72$level2 <- ifelse(!is.na(bioInk_72$typeNatural_level2), bioInk_72$typeNatural_level2, bioInk_72$typeSynthetic_level2)

# bioInk_72$level3 <- ifelse(bioInk_72$typeNatural_level2 == "Protein based", bioInk_72$typeProtein_level3, NA)

############# level 2
bioInk_72$level2 <- ifelse(bioInk_72$typeGeneral_level1 == "Synthetic", bioInk_72$typeSynthetic_level2, NA)

bioInk_72$level2 <- ifelse(!is.na(bioInk_72$level2), bioInk_72$typeNatural_level2, bioInk_72$typeSynthetic_level2)

bioInk_72$level2 <- ifelse(!is.na(bioInk_72$typeNatural_level2), bioInk_72$typeSynthetic_level2, bioInk_72$typeNatural_level2)


#### this works! 
bioInk_72$level2 <- ifelse(bioInk_72$typeGeneral_level1 == "Synthetic", bioInk_72$typeSynthetic_level2, bioInk_72$typeNatural_level2)



#table(bioInk_72$level2)
table(bioInk_72$level3)
## 
##              Agarose            Alginates      Alginates;Other 
##                    2                   11                    1 
##            Collagens    Collagens;Gelatin  Collagens|Collagens 
##                    7                    3                    2 
##           Fibrinogen     Fibrinogen;Other              Gelatin 
##                    1                    1                   24 
##   Gelatin;Fibrinogen        Gelatin;Other Gelatin;Silk-fibroin 
##                    1                    2                    1 
##      Gelatin|Gelatin                Other 
##                    2                    1
# if(bioInk_72$typeGeneral_level1 == "Synthetic"){
# bioInk_72$level2 <- bioInk_72$typeSynthetic_level2
# } else if(bioInk_72$typeGeneral_level1 == "Natural"){
#   bioInk_72$level2 <- bioInk_72$typeNatural_level2
# }else{
#   bioInk_72$level2 <-NA
# }
#   


# rename answers to more easily group them
bioInk_72 <- bioInk_72 %>%
      mutate(level3 = recode(level3, "Collagens" = "Collagen")) %>%
      mutate(level3 = recode(level3, "Collagens;Gelatin" = "Collagen+Gelatin")) %>%
      mutate(level3 = recode(level3, "Collagens|Collagens" = "Collagen")) %>%
      mutate(level3 = recode(level3, "Gelatin|Gelatin" = "Gelatin")) %>%
      mutate(level3 = recode(level3, "Gelatin;Silk-fibroin" = "Gelatin+Silk-fibroin")) %>%
      mutate(level3 = recode(level3, "Gelatin;Fibrinogen" = "Gelatin+Fibrinogen")) %>%
      mutate(level2 = recode(level2, "Poly ethylene glycol (PEG)" = "PEG")) %>% 
      mutate(level2 = recode(level2, "Protein based" = "Protein")) %>% 
      mutate(level2 = recode(level2, "Polysaccharide based" = "Polysaccharide")) %>% 
      mutate(level2 = recode(level2, "dECM based" = "dECM")) %>% 
      mutate(level2 = recode(level2, "Protein based;Polysaccharide based" = "Protein + Poly")) %>% 
mutate(level2 = recode(level2, "Protein based;dECM based" = "Protein + dECM")) %>% 
mutate(level2 = recode(level2, "Polysaccharide based;dECM based" = "Poly + dECM")) %>% 
      mutate(level2 = recode(level2, "Protein based;Polysaccharide based;Other" = "Protein+Poly+MatriGel")) %>% 
      mutate(level2 = recode(level2, "Protein based;Polysaccharide based;dECM based" = "Protein+Poly+dECM")) %>% 
      mutate(level2 = recode(level2, "Protein based;Polysaccharide based|Protein based;Polysaccharide based" = "Protein + Poly")) %>% 
      mutate(level2 = recode(level2, "Protein based|Protein based" = "Protein"))
  
#  Protein based|dECM based
# which(bioInk_72$level2 == "Protein based|dECM based")

# bioInk_72[13, "level2"] <- "Protein based"
# bioInk_72[14, "level2"] <- "dECM based"


bioInk_72[30, "level2"] <- "Protein based"
bioInk_72[31, "level2"] <- "dECM based"


# other in "not reported" should be removed

#### START PLOTTING

library(dplyr)
library(plotme)


bioInk_count <-  count(bioInk_72, 
                       typeGeneral_level1, 
                       level2,
                       level3
                       #,study_ID
                       )


# sunburst plot
plotme::count_to_sunburst(bioInk_count)

Change -

Figure 2b - Cell Densities

cellDensity_num <- tibble(
  study_ID = reconciled$study_ID,
  cellDensity = reconciled$`4.1.3.4.1 Please specify the cell density cells/ml!_a995234c-c94e-4d14-8a6c-fe5bd759b928_Answer`)


cellDensity_num <- separate_rows(cellDensity_num, cellDensity, sep="\\|")
cellDensity_num <- separate_rows(cellDensity_num, cellDensity, sep=";")
cellDensity_num <- separate_rows(cellDensity_num, cellDensity, sep=",")

# remove line breaks
cellDensity_num$cellDensity <- str_replace_all(cellDensity_num$cellDensity, "[\n]" , "")

# convert to e+ for scientific notation conversion
cellDensity_num$cellDensity <- str_replace_all(cellDensity_num$cellDensity, "\\*10E" , "e+")

# remove whitespace from start & end of str
cellDensity_num$cellDensity <- str_trim(cellDensity_num$cellDensity, "left")
cellDensity_num$cellDensity <- str_trim(cellDensity_num$cellDensity, "right")


# rename answers to more easily group them
# cellDensity_num <- cellDensity_num %>% 
#       mutate(cellDensity = recode(cellDensity, "1*10E6" = "microarray spotter")) %>% mutate(cellDensity = recode(cellDensity, "scaffold free bioprinting" = "scaffold-free bioprinting"))

options(scipen = 999)


sorted <- cellDensity_num[order(as.numeric(as.character(cellDensity_num$cellDensity))), ]

freq_table_cell <- cellDensity_num %>% group_by(cellDensity) %>% 
  summarise(n = n())

t16 <- freq_table_cell[order(as.numeric(as.character(freq_table_cell$cellDensity))), ]

t16 <- table(freq_table_cell$cellDensity)

#t16

 # text(x = barplot(t16$cellDensity, ylab = "Number of Inks", ylim=c(0, max(t16$n) + 10), cex.names=1 , col = "#b2df8a"
 #                 # , main = "What is the Reported Cell Density"
 #                 ), y = t16$n + 2, labels = t16$cellDensity, cex = 1)



# cellDensity_num$cellDensity <- as.numeric(cellDensity_num$cellDensity)
# 
# hist <- hist(cellDensity_num$cellDensity, breaks = 500, plot = FALSE)
# 
# 
# plot(hist, freq = TRUE, labels = TRUE)

options(scipen = 0)

Figure 2c - Origin of BioInks

# t8 <- table(reconciled$`4.1.3.2. What is the origin of the bioink?_34ef46b6-34ac-4ddb-a5de-07bc74272fca_Answer`)

bioOrigin <-  reconciled %>%select(
  study_ID, 
    `4.1.3.2. What is the origin of the bioink?_34ef46b6-34ac-4ddb-a5de-07bc74272fca_Answer`
 #, `4.1.3 What type of bioink was used?_92421414-c597-4e9c-b720-9bb4318b5483_Answer`
  ) %>%  separate_rows(`4.1.3.2. What is the origin of the bioink?_34ef46b6-34ac-4ddb-a5de-07bc74272fca_Answer`, sep="\\|")


bioOrigin <- bioOrigin %>% mutate(`4.1.3.2. What is the origin of the bioink?_34ef46b6-34ac-4ddb-a5de-07bc74272fca_Answer`= recode(`4.1.3.2. What is the origin of the bioink?_34ef46b6-34ac-4ddb-a5de-07bc74272fca_Answer`, "commercial (ready-to-use)" = "Commercial")) %>% mutate(`4.1.3.2. What is the origin of the bioink?_34ef46b6-34ac-4ddb-a5de-07bc74272fca_Answer`= recode(`4.1.3.2. What is the origin of the bioink?_34ef46b6-34ac-4ddb-a5de-07bc74272fca_Answer`,"custom formulated" = "Custom" ))


t8 <- table(bioOrigin$`4.1.3.2. What is the origin of the bioink?_34ef46b6-34ac-4ddb-a5de-07bc74272fca_Answer`)

t8
## 
##   Commercial       Custom Not reported      Unclear 
##            6           60            2            4
text(x = barplot(t8, ylab = "Number of BioInks", ylim=c(0, max(t8) + 10), cex.names=1 , col = "#b2df8a"
                 #, main = "What is the origin of BioInk"
                 ), y = t8 + 2, 
     labels = t8, cex = 1)

Figure 2d - Available Meta-data for BioInks

Frequency of reporting and what meta-data was actually reported.

# Maren comment: I think what was reported how often would be most interesting. e.g., 10 out of 34 mentioned the concentration, etc
# 4.1.3.2.3.

custom_bioInk <- tibble( 
   study_ID = reconciled$study_ID, 
   infoProivded =  reconciled$`4.1.3.2.3 If custom formulated, which information is provided for the bioink?_fe62b3e4-d8f1-4584-a90d-e07317e4c8e1_Answer`
 # , comment = reconciled$`4.1.3.2.3 If custom formulated, which information is provided for the bioink?_fe62b3e4-d8f1-4584-a90d-e07317e4c8e1_Comments`
 ) 


custom_bioInk <- separate_rows(custom_bioInk, infoProivded, sep="\\|")
custom_bioInk <- separate_rows(custom_bioInk, infoProivded, sep=";")

# group by numbers
custom_bioInk_count <- custom_bioInk %>%  group_by(infoProivded) %>% summarise(n_studies_report = length(unique(study_ID))) %>%  arrange(desc(n_studies_report))

custom_bioInk_count <- custom_bioInk_count %>%  
                    drop_na(infoProivded)

names(custom_bioInk_count) <- c("Information Provided", "Number of Unique Studies")

library(formattable)

formattable(custom_bioInk_count,
            align =c("l", "r"),
            list(`Indicator Name` = formatter(
              "span", style = ~ style(color = "grey",font.weight = "bold")), 
              `Number of Unique Studies`= color_bar("#b2df8a")
))
Information Provided Number of Unique Studies
Concentration 51
Composition 50
Solvent 42
Storage conditions 7
None 1
#################################
####### How many items were reported? 

custom_bioInk_studies <- custom_bioInk %>%  group_by(study_ID) %>% summarise(n_items_reported = length(unique(infoProivded))) %>%  arrange(desc(n_items_reported)) 

# hist(custom_bioInk_studies$n_items_reported)

t11 <- table(custom_bioInk_studies$n_items_reported)

#barplot(table(custom_bioInk_studies$n_items_reported), ylab = "Number of studies", cex.names=.7, col = "lightblue")

text(x = barplot(t11, ylab = "Number of studies", ylim=c(0, max(t11) + 10), cex.names=1 , col = "#b2df8a"
                 , main = "How many items were reported about custom-formulated bioink?")
     , y = t11 + 2, labels = t11, cex = 1)

Figure 3 - Liver Cells

Figure 3a - What Type of Liver Cells are used?

### combine the ones with semi-colon - into a new category called "Combination"

liver_cells <- reconciled %>% 
  mutate(`2.2 What is the main type of liver cells included?_9bea404f-a75c-401f-af5b-8fd020306538_Answer` = recode(`2.2 What is the main type of liver cells included?_9bea404f-a75c-401f-af5b-8fd020306538_Answer`, "Hepatoma cells;Other" = "Combination")) %>% 
   mutate(`2.2 What is the main type of liver cells included?_9bea404f-a75c-401f-af5b-8fd020306538_Answer` = recode(`2.2 What is the main type of liver cells included?_9bea404f-a75c-401f-af5b-8fd020306538_Answer`, "Primary cells;Other" = "Combination")) %>% 
  mutate(`2.2 What is the main type of liver cells included?_9bea404f-a75c-401f-af5b-8fd020306538_Answer` = recode(`2.2 What is the main type of liver cells included?_9bea404f-a75c-401f-af5b-8fd020306538_Answer`, "primary cells" = "Primary cells"))%>% 
  mutate(`2.2 What is the main type of liver cells included?_9bea404f-a75c-401f-af5b-8fd020306538_Answer` = recode(`2.2 What is the main type of liver cells included?_9bea404f-a75c-401f-af5b-8fd020306538_Answer`, "Induced pluripotent stem cells" = "iPSCs")) 


t9 <- table(liver_cells$`2.2 What is the main type of liver cells included?_9bea404f-a75c-401f-af5b-8fd020306538_Answer`)


t9_sorted<- t9 %>% as.data.frame() %>% arrange(factor(Var1, levels = c("Hepatoma cells", "iPSCs", "Primary cells", "Combination", "Other")))

data_bar9 <- t9_sorted$Freq
names(data_bar9) <- t9_sorted$Var1

text(x = barplot(
#  colnames<-(t(t13_sorted[-1]), t13_sorted[,1]), 
 # 'labels' <- (t(t13_sorted[-1]), t13_sorted[,1])), 
  # t(as.matrix(t13_sorted)), 
   data_bar9,
  ylab = "Number of Studies", ylim=c(0, max(data_bar9) + 10), cex.names=.8 , col = "turquoise", main = "What kind of forms are printed with this ink?"), y = data_bar9 + 2, labels = data_bar9, 
  cex = 0.8)

#barplot(table(reconciled$`2.2 What is the main type of liver cells included?_9bea404f-a75c-401f-af5b-8fd020306538_Answer`), ylab = "Number of studies", cex.names=.5, col = "turquoise")

# text(x = barplot(t9, ylab = "Number of studies", ylim=c(0, max(t9) + 10), cex.names=.8 , col = "turquoise", main = "What type of Liver Cells are included?"), y = t9 + 2, labels = t9, cex = 0.8, )

Figure 3b - What cell cultures were used?

liverType <- tibble(
  study_ID = reconciled$study_ID, 
  liverCells = reconciled$`2.2 What is the main type of liver cells included?_9bea404f-a75c-401f-af5b-8fd020306538_Answer`, 
  liverCellsComment = reconciled$`2.2 What is the main type of liver cells included?_9bea404f-a75c-401f-af5b-8fd020306538_Comments`
)


# remove line breaks
library(stringr)
liverType$liverCellsComment <- str_replace_all(liverType$liverCellsComment, "[\n]" , "")
liverType <- separate_rows(liverType, liverCellsComment, sep=";")

# remove whitespace from start of str
liverType$liverCellsComment <- str_trim(liverType$liverCellsComment, "left")

# remove whitespace from end of str
liverType$liverCellsComment <- str_trim(liverType$liverCellsComment, "right")

# liverType <- liverType %>% 
#       mutate(liverCellsComment = recode(liverCellsComment, "Human iPSC-derived hepatocytes" = "human hepatocytes")) %>% 
#       mutate(liverCellsComment = recode(liverCellsComment, "adult stem cell derived hepatocytes" = "human hepatocytes")) %>% 
#   mutate(liverCellsComment = recode(liverCellsComment, "cholangiocarinoma cells" = "human cells - other")) %>% 
#   mutate(liverCellsComment = recode(liverCellsComment, "bone marrow mesenchymal cells" = "human cells - other")) %>% 
#   mutate(liverCellsComment = recode(liverCellsComment, "hepatic progenitor cells" = "human cells - other")) %>% 
#   mutate(liverCellsComment = recode(liverCellsComment, "hepatic stellate cells" = "human cells - other")) %>% 
#   mutate(liverCellsComment = recode(liverCellsComment, "Hepatocellular carcinoma" = "human cells - other")) %>% 
#     mutate(liverCellsComment = recode(liverCellsComment, "aHSC" = "human cells - other")) %>% 
#     mutate(liverCellsComment = recode(liverCellsComment, "AML12" = "human cells - other")) %>% 
#     mutate(liverCellsComment = recode(liverCellsComment, "hiHep" = "human cells - other")) %>% 
#    mutate(liverCellsComment = recode(liverCellsComment, "hESC lines RC-6 and RC-10" = "human cells - other")) %>% 
#   mutate(liverCellsComment = recode(liverCellsComment, "HMCS1SA" = "human cells - other")) %>% 
#    mutate(liverCellsComment = recode(liverCellsComment, "liver biopsies" = "human liver tissue")) %>% 
#    mutate(liverCellsComment = recode(liverCellsComment, "porcine liver tissue" = "porcine liver tissue"))

# liverType$liverCellsComment




# create categories
liverType$liverCellsComment <- as.factor(liverType$liverCellsComment)

commentsLiver <- liverType %>%  group_by(liverCellsComment) %>% summarise(n_unique = length(unique(study_ID))) %>%  arrange(desc(n_unique))


## remove NA options 
# remove NAs as they dont make sense
commentsLiver <- commentsLiver %>%  
                    drop_na(liverCellsComment)


#install.packages("formattable")
library(formattable)

formattable(commentsLiver,
            align =c("l", "r"),
            list(`Indicator Name` = formatter(
              "span", style = ~ style(color = "grey",font.weight = "bold")), 
              `n_unique`= color_bar("turquoise")
))
liverCellsComment n_unique
HepG2 26
human hepatocytes 11
HepaRG 5
murine hepatocytes 4
Hep3B 3
Huh7 2
AML12 murine cell line 1
bone marrow mesenchymal cells 1
cholangiocarinoma cells 1
hepatic progenitor cells 1
hepatic stellate cells LX2 1
Hepatocellular carcinoma 1
hESCs (RC-6, RC-10) 1
hiHep 1
HMCS1SA 1
liver biopsies 1
miHeps (mouse hepatocyte-like cells) 1
porcine liver tissue 1

Figure 3c - What Type of non-parenchymal cells were included in the co-cultures?

nonParanchymal <- tibble(
  study_ID = reconciled$study_ID, 
  nonParanchymalCellType = reconciled$`2.2.1.1 If co-cultured, what type of non-parenchymal cells are included?_b729a62f-2dc7-47b6-ada7-e1ed8e363918_Answer`, 
  Comment = reconciled$`2.2.1.1 If co-cultured, what type of non-parenchymal cells are included?_b729a62f-2dc7-47b6-ada7-e1ed8e363918_Comments`
)

nonParanchymal <- separate_rows(nonParanchymal, nonParanchymalCellType, sep="\\|")
nonParanchymal <- separate_rows(nonParanchymal, nonParanchymalCellType, sep=";")


# group by numbers
nonParanchymal_count <- nonParanchymal %>%    mutate(nonParanchymalCellType = recode(nonParanchymalCellType, "Other" = "Fibroblasts")) %>% group_by(nonParanchymalCellType) %>% summarise(n_studies_report = length(unique(study_ID))) %>%  arrange(desc(n_studies_report))



# remove NAs as they dont make sense
nonParanchymal_count <- nonParanchymal_count %>%  

                    drop_na(nonParanchymalCellType)

library(formattable)

formattable(nonParanchymal_count,
            align =c("l", "r"),
            list(`Indicator Name` = formatter(
              "span", style = ~ style(color = "grey",font.weight = "bold")), 
              `n_studies_report`= color_bar("turquoise")
))
nonParanchymalCellType n_studies_report
Endothelial cells 19
Fibroblasts 12
Hepatic stellate cells 10
Immune cells 3
Stem cells 3
Epithelial cells 1

Figure 3d - What Meta-data was provided for the Liver Cells?

liverCell_meta <- reconciled %>% mutate(`2.4 Which kind of meta data is available for the used liver cells?_2868ee50-2c4c-47e8-a040-427e4f882632_Answer` = recode(`2.4 Which kind of meta data is available for the used liver cells?_2868ee50-2c4c-47e8-a040-427e4f882632_Answer`, "Common cell line;None" = "Common cell line"))

liverMetaData <- separate_rows(liverCell_meta, `2.4 Which kind of meta data is available for the used liver cells?_2868ee50-2c4c-47e8-a040-427e4f882632_Answer` ,sep=";")


liverMetaData_heat <- liverMetaData[,c(1, 58)]

colnames(liverMetaData_heat) <- c("study_ID", "metaData")

countsMetaDat <- liverMetaData_heat %>% group_by(study_ID) %>% summarize(n_unique = length(unique(metaData)))

t10 <- table(countsMetaDat$n_unique)
#  1  2  3 
# 56  2  5 


hist(countsMetaDat$n_unique, xlab = "Number of Meta-Data Items Reported", ylab = "Number of Papers", main = "Meta-Data Items about the Cell Lines Peformed per Paper", breaks = 3)

## convert to facotrs to display barplot
 countsMetaDat$n_unique <- as.factor(countsMetaDat$n_unique)


text(x = barplot(t10, ylab = "Number of Meta-Data Items", ylim=c(0, max(t10) + 10), cex.names=.8 , col = "turquoise", main = "How many meta-data items are reported about the liver cells?"), y = t10 + 2, labels = t10, cex = 0.8)

Figure 3e - Additives

### Additives
# -- needs cleaning 
# table(reconciled$`4.1.3.3 Which information is provided on the additives in the ink or culture? _4c2b5908-9c3c-4ba8-91f2-dd9771ac2ad4_Answer`)
# needs cleaning

liverAdditive <- tibble(
  study_ID = reconciled$study_ID, 
  additive = reconciled$`4.1.3.3 Which information is provided on the additives in the ink or culture? _4c2b5908-9c3c-4ba8-91f2-dd9771ac2ad4_Answer`
)


liverAdditive <- separate_rows(liverAdditive, additive, sep="\\|")
liverAdditive <- separate_rows(liverAdditive, additive, sep=";")

# group by numbers
liverAdditive_count <- liverAdditive %>%  group_by(additive) %>% summarise(n_studies_report = length(unique(study_ID))) %>%  arrange(desc(n_studies_report))

library(formattable)

formattable(liverAdditive_count,
            align =c("l", "r"),
            list(`Indicator Name` = formatter(
              "span", style = ~ style(color = "grey",font.weight = "bold")), 
              `n_studies_report`= color_bar("turquoise")
))
additive n_studies_report
Concentration 50
Manufacturer 42
None 13
Order number 10
#################################
####### How many items were reported? 

additives_studies <- liverAdditive %>%  group_by(study_ID) %>% summarise(n_items_reported = length(unique(additive))) %>%  arrange(desc(n_items_reported)) 

# hist(custom_bioInk_studies$n_items_reported)

t12 <- table(additives_studies$n_items_reported)

#barplot(table(custom_bioInk_studies$n_items_reported), ylab = "Number of studies", cex.names=.7, col = "lightblue")

text(x = barplot(t12, ylab = "Number of studies", ylim=c(0, max(t12) + 10), cex.names=.8 , col = "turquoise", main = "How many items were reported about bioink or co-culture additives?"), y = t12 + 2, labels = t12, cex = 0.8)

###################################################
## 2.1.1.1 - if xeno free

additives <- tibble(
  study_ID = reconciled$study_ID, 
  additive = reconciled$`2.1.1.1 If not xeno-free, which additives are included in the study?_39f4070b-a7cd-4b06-9618-47e07363219c_Answer`
)

additives <- separate_rows(additives, additive, sep="\\|")
additives <- separate_rows(additives, additive, sep=";")


# group by numbers
Additive_count <- additives %>%  group_by(additive) %>% summarise(n_studies_report = length(unique(study_ID))) %>%  arrange(desc(n_studies_report))

library(formattable)

formattable(Additive_count,
            align =c("l", "r"),
            list(`Indicator Name` = formatter(
              "span", style = ~ style(color = "grey",font.weight = "bold")), 
              `n_studies_report`= color_bar("turquoise")
))
additive n_studies_report
Fetal Bovine Serum (FBS) 37
Gelatin 27
NA 20
Other 12
Matrigel 9
Bovine Serum Albumin (BSA) 8
Collagen 8
Basement Membrane Extracts (BME) 1
#### 2.1.2 - Animal 

additivesAnimal <- tibble(
  study_ID = reconciled$study_ID, 
  additive = reconciled$`2.1.2 If animal, which of the following additives are included in the study?_bd00875c-4d61-4449-8629-6ff8fab20ec5_Answer`
)



additivesAnimal <- separate_rows(additivesAnimal, additive, sep="\\|")
additivesAnimal <- separate_rows(additivesAnimal, additive, sep=";")


# group by numbers
AdditiveAnimal_count <- additivesAnimal %>%  group_by(additive) %>% summarise(n_studies_report = length(unique(study_ID))) %>%  arrange(desc(n_studies_report))

library(formattable)

formattable(AdditiveAnimal_count,
            align =c("l", "r"),
            list(`Indicator Name` = formatter(
              "span", style = ~ style(color = "grey",font.weight = "bold")), 
              `n_studies_report`= color_bar("turquoise")
))
additive n_studies_report
NA 59
Fetal Bovine Serum (FBS) 3
Collagen 1
Gelatin 1
Not reported 1
Other 1
#### 2.1.3 - if both
additivesBoth <- tibble(
  study_ID = reconciled$study_ID, 
  additive = reconciled$`2.1.3 If both, which of the following additives are included in the study?_648859a8-3da6-4d7e-b457-d3443a608681_Answer`
)

additivesBoth <- separate_rows(additivesBoth, additive, sep="\\|")
additivesBoth <- separate_rows(additivesBoth, additive, sep=";")


# group by numbers
AdditiveBoth_count <- additivesBoth %>%  group_by(additive) %>% summarise(n_studies_report = length(unique(study_ID))) %>%  arrange(desc(n_studies_report))

library(formattable)

formattable(AdditiveBoth_count,
            align =c("l", "r"),
            list(`Indicator Name` = formatter(
              "span", style = ~ style(color = "grey",font.weight = "bold")), 
              `n_studies_report`= color_bar("turquoise")
))
additive n_studies_report
NA 49
Fetal Bovine Serum (FBS) 14
Gelatin 5
Bovine Serum Albumin (BSA) 2
Collagen 2
Matrigel 1
Other 1
##### Combine animal, if not xeno-free and both 

additivesCombo <- tibble(
  study_ID = reconciled$study_ID, 
  additive_xeno = reconciled$`2.1.1.1 If not xeno-free, which additives are included in the study?_39f4070b-a7cd-4b06-9618-47e07363219c_Answer`,
  additive_both = reconciled$`2.1.3 If both, which of the following additives are included in the study?_648859a8-3da6-4d7e-b457-d3443a608681_Answer`, 
    additive_animal = reconciled$`2.1.2 If animal, which of the following additives are included in the study?_bd00875c-4d61-4449-8629-6ff8fab20ec5_Answer`
  
)

additivesCombo <- separate_rows(additivesCombo, additive_xeno, sep="\\|")
additivesCombo <- separate_rows(additivesCombo, additive_xeno, sep=";")

additivesCombo <- separate_rows(additivesCombo, additive_both, sep="\\|")
additivesCombo <- separate_rows(additivesCombo, additive_both, sep=";")

additivesCombo <- separate_rows(additivesCombo, additive_animal, sep="\\|")
additivesCombo <- separate_rows(additivesCombo, additive_animal, sep=";")


### merge level 2 & merge level 3 
# additivesCombo$additives_all <- ifelse(!is.na(additivesCombo$additive_animal), additivesCombo$additive_animal, additivesCombo$additive_both)
# additivesCombo$additives_all <- ifelse(!is.na(additivesCombo$additive_both), additivesCombo$additive_both, additivesCombo$additive_xeno)


additivesCombo <-  additivesCombo %>% unite("additives_all", c("additive_animal","additive_both", "additive_xeno"), na.rm = TRUE, remove = FALSE) %>% 
  subset(study_ID != "4d390c76-69b1-4a62-9805-72659c3be47b") %>% 
  subset(study_ID != "0a879122-3ef7-4fb8-85fb-d87cd7622675")


additivesCombo_count <- additivesCombo %>%  group_by(additives_all) %>% summarise(n_studies_report = length(unique(study_ID))) %>%  arrange(desc(n_studies_report))

library(formattable)

formattable(additivesCombo_count,
            align =c("l", "r"),
            list(`Indicator Name` = formatter(
              "span", style = ~ style(color = "grey",font.weight = "bold")), 
              `n_studies_report`= color_bar("turquoise")
))
additives_all n_studies_report
Fetal Bovine Serum (FBS) 54
Gelatin 33
Other 14
Collagen 11
Bovine Serum Albumin (BSA) 10
Matrigel 10
Basement Membrane Extracts (BME) 1
Not reported 1

Figure 4 - Model Conditions and Measurements

Figure 4a

t13 <- table(reconciled$`5.2 How long were the liver models cultured after printing?_1f136f0a-786b-4e17-a97d-e5cf32f47b26_Answer`)
        # < 72 hours 2 weeks - 3 months   3 days - 2 weeks       not reported 
        #          2                 16                 42                  3 
#t13 <- data.table(t13)

# manually set levels 

t13_sorted<- t13 %>% as.data.frame() %>% arrange(factor(Var1, levels = c("< 72 hours", "3 days - 2 weeks", "2 weeks - 3 months", "not reported")))

# library(data.table)

# setcolorder(t13$V1, c("< 72 hours", "3 days - 2 weeks", "2 weeks - 3 months", "not reported"))


# barplot(table(reconciled$`5.2 How long were the liver models cultured after printing?_1f136f0a-786b-4e17-a97d-e5cf32f47b26_Answer`), ylab = "Number of studies", cex.names=.5, col = "purple")

# reconciled$`5.2 How long were the liver models cultured after printing?_1f136f0a-786b-4e17-a97d-e5cf32f47b26_Answer` <- as.factor(reconciled$`5.2 How long were the liver models cultured after printing?_1f136f0a-786b-4e17-a97d-e5cf32f47b26_Answer`)
# 
# levels(reconciled$`5.2 How long were the liver models cultured after printing?_1f136f0a-786b-4e17-a97d-e5cf32f47b26_Answer`)
# 
# reconciled$`5.2 How long were the liver models cultured after printing?_1f136f0a-786b-4e17-a97d-e5cf32f47b26_Answer` <- factor(reconciled$`5.2 How long were the liver models cultured after printing?_1f136f0a-786b-4e17-a97d-e5cf32f47b26_Answer`, levels = c("< 72 hours", "3 days - 2 weeks", "2 weeks - 3 months", "not reported"))
# 
# levels(reconciled$`5.2 How long were the liver models cultured after printing?_1f136f0a-786b-4e17-a97d-e5cf32f47b26_Answer`)
# 
# reconciled2 <- reconciled[order(levels(reconciled$`5.2 How long were the liver models cultured after printing?_1f136f0a-786b-4e17-a97d-e5cf32f47b26_Answer`)),]
# 
# t13 <- table(time_coculture$`5.2 How long were the liver models cultured after printing?_1f136f0a-786b-4e17-a97d-e5cf32f47b26_Answer`)

data_bar13 <- t13_sorted$Freq
names(data_bar13) <- t13_sorted$Var1


barplot(data_bar13)

text(x = barplot(
#  colnames<-(t(t13_sorted[-1]), t13_sorted[,1]), 
 # 'labels' <- (t(t13_sorted[-1]), t13_sorted[,1])), 
  # t(as.matrix(t13_sorted)), 
   data_bar13,
  ylab = "Number of Studies", ylim=c(0, max(data_bar13) + 10), cex.names=.8 , col = "purple", main = "How long were liver models cultured?"), y = data_bar13 + 2, labels = data_bar13, 
  cex = 0.8)

Figure 4b- What Liver Proteins were measured?

# otherLiverMetabolite <- liverMetabolite_comments %>%  group_by(`6.4 Which metabolites were analyzed in the study?_5652d702-1441-4234-b37d-f0b44d64c5e9_Comments`) %>% summarise(n_unique = length(unique(study_ID))) %>%  arrange(desc(n_unique))

# otherLiverMetabolite <- otherLiverMetabolite %>% 
#   drop_na(`6.4 Which metabolites were analyzed in the study?_5652d702-1441-4234-b37d-f0b44d64c5e9_Comments`)


liverMetabolite <- tibble(
  study_ID = reconciled$study_ID, 
  metabolite = reconciled$`6.4 Which metabolites were analyzed in the study?_5652d702-1441-4234-b37d-f0b44d64c5e9_Answer`, 
  comment = reconciled$`6.4 Which metabolites were analyzed in the study?_5652d702-1441-4234-b37d-f0b44d64c5e9_Comments`
) 


liverMetabolite <- separate_rows(liverMetabolite, metabolite, sep="\\|")
liverMetabolite <- separate_rows(liverMetabolite, metabolite, sep=";")


liverMetabolite <- liverMetabolite %>%  group_by(metabolite) %>% summarise(n_unique = length(unique(study_ID))) %>%  arrange(desc(n_unique))


# remove NAs as they dont make sense
liverMetabolite <- liverMetabolite[liverMetabolite$metabolite != "None" ,]


#install.packages("formattable")
library(formattable)

formattable(liverMetabolite,
            align =c("l", "r"),
            list(`Indicator Name` = formatter(
              "span", style = ~ style(color = "grey",font.weight = "bold")), 
              `n_unique`= color_bar("yellow")
))
metabolite n_unique
Albumin 47
Urea 24
Other 7
Bile acid 3
#### CLEAN THIS!! 
# formattable(otherLiverMetabolite, 
#              align = c("l", "r"), 
#              list(`Indicator Name` = formatter(
#               "span", style = ~ style(color = "grey",font.weight = "bold")), 
#               `n_unique`= color_bar("yellow")
#             
#             ))

Figure 4c - What Cytochome Isoforms were measured?

# liverCytochome <- separate_rows(reconciled, `6.2.1 If yes, which cytochrome isoforms were analysed?_62bdffd7-d9c7-4646-9f66-9510f5bf2649_Answer`
#    ,sep=";")

liverCytochome_only <- tibble(
  study_ID = reconciled$study_ID, 
  cytochrome = reconciled$`6.2.1 If yes, which cytochrome isoforms were analysed?_62bdffd7-d9c7-4646-9f66-9510f5bf2649_Answer`
) 


liverCytochome_only <- separate_rows(liverCytochome_only, cytochrome, sep="\\|")
liverCytochome_only <- separate_rows(liverCytochome_only, cytochrome, sep=";")


liverCytochome_only_count <- liverCytochome_only %>%  group_by(cytochrome) %>% summarise(n_unique = length(unique(study_ID))) %>%  arrange(desc(n_unique))


# remove NAs as they dont make sense
liverCytochome_only_count <- liverCytochome_only_count %>%  
                    drop_na(cytochrome)

liverCytochome_only_count$cytochrome
## [1] "CYP3A"        "CYP1A"        "CYP2B"        "CYP2C"        "CYP2D"       
## [6] "CYP2E"        "Not reported" "CYP1A2"       "YP2C"
liverCytochome_only_count <- liverCytochome_only_count %>% 
  mutate(cytochrome = recode(cytochrome, "YP2C" = "CYP2C"))

formattable(liverCytochome_only_count,
            align =c("l", "r"),
            list(`Indicator Name` = formatter(
              "span", style = ~ style(color = "grey",font.weight = "bold")), 
              `n_unique`= color_bar("yellow")
))
cytochrome n_unique
CYP3A 21
CYP1A 15
CYP2B 5
CYP2C 5
CYP2D 5
CYP2E 4
Not reported 2
CYP1A2 1
CYP2C 1

Figure 4d - Storage Conditions

t14 <- table(reconciled$`5.1 Does the study report the storage conditions of the printed models?_0adebee3-f3bc-4b01-a756-f8a93dc7b5bc_Answer`)


text(x = barplot(t14, ylab = "Number of Studies", ylim=c(0, max(t14) + 10), cex.names=.8 , col = "purple", main = "Were storage conditions reported?"), y = t14 + 2, labels = t14, cex = 0.8)

Figure 4d - Frequency of Assays Used

# 5.3.1

assays <- tibble(
  study_ID = reconciled$study_ID, 
  assay = reconciled$`5.3.1 Which assays were performed to assure the quality of the liver model?_8a415412-28c6-48ff-840a-538ea69a068f_Answer`
) 

assays <- separate_rows(assays, assay, sep="\\|")
assays <- separate_rows(assays, assay, sep=";")


assays <- assays %>%  group_by(assay) %>% summarise(n_unique = length(unique(study_ID))) %>%  arrange(desc(n_unique))


# remove NAs as they dont make sense
assays <- assays %>%  
                    drop_na(assay)


customPurple = "#C5B4E3"

formattable(assays,
            align =c("l", "r"),
            list(`Indicator Name` = formatter(
              "span", style = ~ style(color = "grey",font.weight = "bold")), 
              `n_unique`= color_bar(customPurple)
))
assay n_unique
Viability test 47
Histological characterization 45
Live/Dead Cell Staining 44
Enzyme linked immunosorbent Assay (ELISA) of liver markers 30
Real-time quantitative PCR of liver markers 28
Rheological test 23
Mechanical stiffness 15
Size measurement 13
Biodegradation 4
Biocompatibility 3

Figure 4e - Agonists

# 6.3.1 


agonists <- tibble(
  study_ID = reconciled$study_ID, 
  agonist = reconciled$`6.3.1  Please specify the agonists of the receptors that are applied._d42bd778-8656-4e6b-8b11-e4bdecb6a9b9_Answer`, 
  agonistsComment = reconciled$`6.3.1  Please specify the agonists of the receptors that are applied._d42bd778-8656-4e6b-8b11-e4bdecb6a9b9_Comments`
)


agonists <- separate_rows(agonists, agonist, sep="\\|")
agonists <- separate_rows(agonists, agonist, sep=";")


agonists <- separate_rows(agonists, agonistsComment, sep="\\|")
agonists <- separate_rows(agonists, agonistsComment, sep=";")

# remove line breaks
agonists$agonistsComment <- str_replace_all(agonists$agonistsComment, "[\n]" , "")
# remove whitespace from start of str
agonists$agonistsComment <- str_trim(agonists$agonistsComment, "left")

# remove whitespace from end of str
agonists$agonistsComment <- str_trim(agonists$agonistsComment, "right")

agonists_count <- agonists %>%  group_by(agonist) %>% summarise(n_unique = length(unique(study_ID))) %>%  arrange(desc(n_unique))


# remove NAs/None as they dont make sense
# liverMetabolite <- liverMetabolite[liverMetabolite$metabolite != "None" ,]


#install.packages("formattable")
library(formattable)

customPurple = "#C5B4E3"

formattable(agonists_count,
            align =c("l", "r"),
            list(`Indicator Name` = formatter(
              "span", style = ~ style(color = "grey",font.weight = "bold")), 
              `n_unique`= color_bar(customPurple)
))
agonist n_unique
NA 55
Other 7
Pregnane X receptor (PXR) 1
table(agonists$agonistsComment)
## 
## Acetaminophen    Omeprazole phenobarbital    rifampicin    Rifampicin 
##             1             2             1             1             6
agonists$study_ID
##  [1] "0b78f899-524b-49df-8b02-bdb64e281ed4"
##  [2] "f0faaae5-eba2-4213-afe0-d958d5279121"
##  [3] "487b3d85-d671-40f2-8d60-309a6aa9a4f3"
##  [4] "d21360df-70ad-426a-b86e-b6eccebcbe11"
##  [5] "d21360df-70ad-426a-b86e-b6eccebcbe11"
##  [6] "11abf440-c03a-4830-9c5d-4e3688fe8808"
##  [7] "6955f074-b9f4-4f46-b6a8-06b49f150239"
##  [8] "13e55d40-f8a1-43bd-98ca-32db20c905cd"
##  [9] "2a8a7137-e063-43ca-aeaa-f6b69913cfd4"
## [10] "da06262f-dc22-4def-aba7-cce50b42dcf5"
## [11] "da06262f-dc22-4def-aba7-cce50b42dcf5"
## [12] "cd0fbda8-6e94-4896-9f27-c033a7487a71"
## [13] "da0e9699-c87a-44e0-b84c-4b14be9daaad"
## [14] "c1e0df1e-ce83-44b0-b2e4-19c3f56aa7ff"
## [15] "848c1eee-8b25-40f7-984b-4cfdb05f0241"
## [16] "462e62fd-cc0a-4a32-8198-2ed6a84c322c"
## [17] "24fb928e-979e-4228-b369-0edd3b339884"
## [18] "ba319be5-988a-44d2-86a1-f75330dd9da3"
## [19] "0d23ac08-a568-4b1a-a6c2-01d19d288bdf"
## [20] "0d23ac08-a568-4b1a-a6c2-01d19d288bdf"
## [21] "4d57bd86-4d33-4783-909f-1e1a18d882ca"
## [22] "d4948c0b-3d1d-476b-a1b5-fb91b5d982ed"
## [23] "b058b903-8388-4d2e-8b43-69ff6a0453ef"
## [24] "cebd5710-c09b-4a96-b00a-c58fa7e18d1c"
## [25] "0d85585e-2b72-406c-939d-c404231fc8d0"
## [26] "c3527bf9-8263-4852-ae6d-b2da363d5ae3"
## [27] "dffd19b3-9004-444c-a533-db026c119b04"
## [28] "e617ad33-aa4b-434c-a8e9-6bfe28adef07"
## [29] "c496b10a-b240-46e4-a2a7-45248f3d203e"
## [30] "a97c06ee-aab2-4ff0-870a-4d89a0929c93"
## [31] "59d20a39-39be-4e0b-b1f0-e26dd9d6a146"
## [32] "b519a555-37a6-4e33-bc92-6fe45b826c24"
## [33] "1322a77e-b137-4ee4-8e97-1703409a90ab"
## [34] "9c546424-5433-4bf9-80ff-e69f61f2f49d"
## [35] "7da72e9a-54da-41cc-a251-827f497a7b29"
## [36] "fa560b55-2d34-414b-9203-2005be547aeb"
## [37] "7cde858a-3bf5-41d2-983e-3cf5f23c184e"
## [38] "09270802-98b4-488b-a134-ef07b2cf1ed9"
## [39] "5de29a15-8d70-47ad-b21b-dc8d648723e8"
## [40] "0a879122-3ef7-4fb8-85fb-d87cd7622675"
## [41] "ce0c0c5b-9add-4759-a53f-c51194916ba1"
## [42] "07bf04fb-5d8c-43a7-b9e4-dff867c08748"
## [43] "f265e523-033a-4220-9d69-e9d6acede6c8"
## [44] "9d806aa7-378b-4a4f-ac77-4512d8f91ef3"
## [45] "413b9ef9-44c0-454e-a45e-0b087889e5d4"
## [46] "9ba14487-892c-4714-b47c-d489ca0d7cf8"
## [47] "2d36e179-08b7-48e9-bd05-0ea37aa8c615"
## [48] "ba4dbd9a-d7c7-46d9-a6b9-c27666c27f5c"
## [49] "f66d5b6b-66b3-4885-b1c9-83b14fcde463"
## [50] "0ed43e29-3aa2-4090-bf63-82c07213a741"
## [51] "80639a10-fa1b-4ae6-bf84-143ded2cf4f2"
## [52] "8102db26-59db-4072-9983-4a6cf0f94d84"
## [53] "dd537f81-29b4-433e-ad03-74650686a641"
## [54] "73ec2790-6730-4074-8ff6-7afc58675e3b"
## [55] "ed607f18-b68d-4576-b4a8-6965c86c6bd3"
## [56] "f34645f3-d5c7-4eb6-98be-92a4109db6ed"
## [57] "0a2dc2f4-21ea-4770-bdf8-999c5be9a300"
## [58] "4da32742-6092-4a68-9a73-0633dc1a5682"
## [59] "4d390c76-69b1-4a62-9805-72659c3be47b"
## [60] "d7857cd3-723d-4d74-8b81-7088ad787433"
## [61] "41e2d206-d3a4-42c0-b85a-07e2d17b0236"
## [62] "d95b99b0-509b-41a9-962a-de33e4172f8e"
## [63] "b1e76a8a-dc78-467e-820e-89c800ba1060"
## [64] "36c5fb58-7dc0-4bf6-ac6e-ea88b2f878ea"
## [65] "3b0e30ad-a7c3-42b4-a976-1fc9bff5a126"
## [66] "86a0a5f6-8c5f-4c38-8022-924f925996e6"
agonists <- agonists %>%  
mutate(agonistsComment = recode(agonistsComment, "rifampicin" = "Rifampicin")) %>% 
mutate(agonistsComment = recode(agonistsComment, "Rifampicin " = "Rifampicin")) %>%   
  mutate(agonistsComment = recode(agonistsComment, "phenobarbital" = "Phenobarbital")) %>%
subset(study_ID != "0a2dc2f4-21ea-4770-bdf8-999c5be9a300")

 

agonists_comment_count <- agonists %>%  group_by(agonistsComment) %>% summarise(n_unique = length(unique(study_ID))) %>%  arrange(desc(n_unique))



# remove NAs as they dont make sense
agonists_comment_count <- agonists_comment_count %>%  
                    drop_na(agonistsComment)

formattable(agonists_comment_count,
            align =c("l", "r"),
            list(`Indicator Name` = formatter(
              "span", style = ~ style(color = "grey",font.weight = "bold")), 
              `n_unique`= color_bar(customPurple)
))
agonistsComment n_unique
Rifampicin 7
Omeprazole 2
Acetaminophen 1
Phenobarbital 1

Figure 5 - Applications

# Application 
t15 <- table(reconciled$`7.1 Do the authors apply the model in the study?_a6895d38-a9ed-4605-a092-4f06ebbd9e2b_Answer`)
 # No Yes 
 # 35  28 



text(x = barplot(t15, ylab = "Number of Studies", ylim=c(0, max(t15) + 10), cex.names=.8 , col = "gray", main = "Do authors apply the model in the study?"), y = t15 + 2, labels = t15, cex = 0.8)

###########################################################
# field of application 
#table(reconciled$`7.1.1 please select the field of application. _d332c2ee-9864-434f-8595-90305808e32d_Answer`)


applications <- tibble(
  study_ID = reconciled$study_ID, 
  application = reconciled$`7.1.1 please select the field of application. _d332c2ee-9864-434f-8595-90305808e32d_Answer`
)


applications <- separate_rows(applications, application, sep="\\|")
applications <- separate_rows(applications, application, sep=";")

applications_count <- applications %>%  group_by(application) %>% summarise(n_unique = length(unique(study_ID))) %>%  arrange(desc(n_unique))


# remove NAs/None as they dont make sense
# liverMetabolite <- liverMetabolite[liverMetabolite$metabolite != "None" ,]
applications_count <- applications_count %>%  
                    drop_na(application)

#install.packages("formattable")
library(formattable)

customPurple = "#C5B4E3"

formattable(applications_count,
            align =c("l", "r"),
            list(`Indicator Name` = formatter(
              "span", style = ~ style(color = "grey",font.weight = "bold")), 
              `n_unique`= color_bar("lightgrey")
))
application n_unique
Toxicity testing 15
Drug dosage testing 9
Disease modeling 5
Other 4
Xenograft (implantation into animal) 3
Implant / Medical surgery 1

Supplementary Figures

Printer Forms Over Times

printer_form_year<- table(printer_forms$`4.1.4 What kind of forms are printed with this ink?_01d3ca37-1e2f-4087-8f39-c183f98f0c4e_Answer`, printer_forms$NA_Year)


printer_form_yearDF <- as.data.frame(printer_form_year)
# long to wide 
printer_form_yearDF <- printer_form_yearDF %>% spread(
   key = Var2, 
   value = Freq)


# printer_form_yearDF 
# names(printer_form_yearDF) <- gsub(x = names(printer_form_yearDF), pattern = "X", replacement = "")  


library(formattable)

formattable(printer_form_yearDF,
            #align =c("l", "r"),
            list(
              `Indicator Name` = formatter(
              "span", 
              style = ~ style(color = "grey",font.weight = "bold")), 
             area(row = 1:4) ~ color_tile("white", "green")))
## Warning in gradient(as.numeric(x), ...): NAs introduced by coercion
Var1 2010 2011 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022
Grid 0 0 0 1 0 3 4 4 1 5 5 0
Lobular Liver 0 0 0 0 0 1 0 3 1 2 2 1
Other 1 1 1 0 1 4 2 6 3 5 2 3
Toroids 0 0 0 0 1 0 0 0 0 0 0 0